package org.spring.springboot.service.impl;

import org.spring.springboot.dao.CityDao;
import org.spring.springboot.domain.City;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CityServiceImpl implements CityService{
    @Autowired
    private CityDao cityDao;

    public City findCityByName(String cityName) {
        return cityDao.findByName(cityName);
    }
    @Override
    public void insertCityA() {
        City a = new City();
        int id = (int) (java.lang.Math.random() * 100000);
        a.setId(id);
        a.setProvinceId(id);
        a.setCityName("Shanghai");
        a.setDescription("Shanghai City");
        cityDao.insertCityA(a);
    }
    @Override
    public void insertCityB() {
        City a = new City();
        int id = (int) (java.lang.Math.random() * 100000);
        a.setId(id);
        a.setProvinceId(id);
        a.setCityName("Beijing");
        a.setDescription("Beijing City");
        cityDao.insertCityB(a);
    }
}
